Row-level security in a relational database management system

ABSTRACT

Access control methods provide multilevel and mandatory access control for a database management system. The access control techniques provide access control at the row level in a relational database table. The database table contains a security label column within which is recorded a security label that is defined within a hierarchical security scheme. A user&#39;s security label is encoded with security information concerning the user. When a user requests access to a row, a security mechanism compares the user&#39;s security information with the security information in the row. If the user&#39;s security dominates the row&#39;s security, the user is given access to the row.

CROSS-REFERENCE TO RELATED PATENT APPLICATION

This is a continuation of application Ser. No. 12/242,038 filed Sep. 30,2008 which is a continuation of application Ser. No. 11/746,896 filedMay 10, 2007, now patented U.S. Pat. No. 7,464,080, issued Dec. 9, 2008,which is a continuation of application Ser. No. 10/233,397 filed Sep. 4,2002, now patented U.S. Pat. No. 7,240,046, issued Jul. 3, 2007. Theentire disclosure of the prior applications, application Ser. Nos.10/233,397, 11/746,896 and 12/242,038, are hereby incorporated byreference.

BACKGROUND OF THE INVENTION

Field of the Invention

The invention relates to information processing systems, and moreparticularly to methods for providing security in database managementsystems.

Description of the Related Art

With the growth of the World-Wide Web (“web”) and e-business solutions,database security and privacy are becoming increasingly critical.Hosting a web site on a server, referred to as web hosting, is anothertrend that magnifies the importance of database security. The web serverincludes a relational database storing a customer's data in many relatedtables. A web hosting company is motivated to store data from manycustomers in a single database management system to minimize itsexpenses. However, an increasing number of customers need a higherdegree of security than is available with database management systemsconventionally used by hosting companies, especially when the databasemanagement system is used to host more than one customer's web site anddata.

Some customers need mandatory access controls in which all access to adata item, such as a database row, is controlled. Many customers alsoneed to use a hierarchical security scheme that simultaneously supportsmultiple levels of access control. These concepts of mandatory accesscontrols and hierarchical security schemes are well known. They aredescribed, for example, in a Department of Defense standard DoD5200.28-STD, Department of Defense Trusted Computer System EvaluationCriteria, December 1985, which is incorporated by reference herein.

Conventional relational databases, such as the database described inU.S. Pat. No. 5,751,949 to Thomson et al., provide security based ontables and views of those tables. Views can be used to limit access toselected rows and columns within one or more database tables. Forexample, in Thomson et al., views are used to join data tables with asecurity table containing user authorization information. Certain users,however, such as system administrators can bypass views and accesstables directly, thereby circumventing the access control provided byviews. Also, it is often cumbersome for the database administrator andapplication programmer to construct views that have the desired level ofgranularity. Although views can be effective for read-only access, viewsare more difficult to define for updating, inserting and deleting.Triggers, database constraints and stored procedures are often neededfor update controls.

Although many applications need row-level security within a relationaldatabase so that individual user access can be restricted to a specificset of rows, there is a need to make the security control mandatory.With mandatory access control, users, application programmers anddatabase administrators are unable to bypass the row-level securitymechanism.

SUMMARY OF THE INVENTION

The methods described here provide mandatory row-level security within arelational database. They offer many advantages over conventionaldatabase systems that are available today. They can provide a securityenforcement mechanism that is mandatory and automatic, that canimplement security schemes that would be difficult to express in atraditional Structured Query Language (SQL) view or query, and achieveperformance optimizations that minimize processing requirements andelapsed time overhead associated with making row-level security checks.The methods described here also provide a security enforcement mechanismthat does not have to rely upon special views or database sessionvariables to provide row-level security controls.

An embodiment of the invention relates to a method of controlling accessto a relational database. The method includes receiving a user requestfor data from the database, in which the request includes a request toperform a database operation and a user security label. User securityinformation is determined from the user security label. In response tothe user request, rows of data are retrieved from a table in thedatabase that satisfy the database operation, in which the rows eachhave a security label. The method further includes determining rowsecurity information for each of the retrieved rows based on the row'ssecurity label. For each retrieved row the method determines whether theuser is authorized to access the row based on the user securityinformation and the row security information. Only the rows for whichthe user is determined to have authorization to access are returned.

The request from a user does not need to contain a query of a view nordoes it require a join of a table containing access control information,in order to limit user access to the database.

Features and advantages of the invention will become apparent uponconsideration of the following descriptions and descriptive figures ofspecific embodiments thereof. While these descriptions go into specificdetails of the invention, it should be understood that variations mayand do exist and would be apparent to those skilled in the art based onthe descriptions herein.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a block diagram showing a web host having a conventionaldatabase management system managing data for more than one web site.

FIGS. 2A-D show a database table, SQL statements to create a view, theview, and a query, respectively, that are used in conventional methodsfor limiting a user's access to certain rows of data in the databasetable.

FIG. 3 is a block diagram showing an access control system that includesa database management system with a read mandatory security enforcementunit and a write mandatory security enforcement unit that supportrow-level access control that enables mandatory access control.

FIG. 4 shows an example of a security hierarchy scheme supported by theaccess control system shown in FIG. 3.

FIGS. 5A and B show a query, a database table and a security mechanismemploying the security hierarchy illustrated in FIG. 4. The query can beapplied to the database table using mandatory row-level securityenforcement provided by the security mechanism.

FIG. 6 illustrates the use of a cache in the database management systemshown in FIG. 3 to improve performance when providing row-levelmandatory access control.

FIGS. 7A and B are flowcharts for querying a database management systemthat provides mandatory row-level access control.

FIGS. 8A-C are flowcharts illustrating sending a request for a rowupdate and updating the row in a database management system thatprovides mandatory row-level access control.

DETAILED DESCRIPTION

The embodiments described below are described with reference to theabove drawings, in which like reference numerals designate likecomponents.

Certain conventional database management systems (DBMS) provide somecapabilities to limit access to rows within the database. However, thoseconventional systems rely on a database administrator to create viewsthat restrict access to the desired rows. The application programmermust then use those special views to enforce the security controls.Often, the application programmer must populate session variables withvalues that the views use to control access to the data rows. Althoughsuch conventional systems do allow a programmer to control access to thedata, those conventional systems suffer from several disadvantages.

For example, conventional DBMSs use views to control access to adatabase. Using views to control access to the database is cumbersomefor the database administrator and the application programmer toimplement. For example, it is common to have to create separate viewsfor each security level (e.g., a TOP SECRET VIEW, a SECRET VIEW, etc.)in the security scheme.

Using views to control access is also error prone, since it is easy toimplement the views incorrectly and inadvertently permit access to thewrong data rows. Also, some security schemes are difficult to express asadditional predicates on the view or user query. There is a need toautomatically enforce access to the data such that no changes arerequired to the user application logic or views.

The security policy achieved using views is only discretionary ratherthan mandatory. A person with database administrator authority is ableto view the data in the database without using the special views thatimplement the security mechanism. There is a need to provide mandatorysecurity controls that prevent unauthorized access by end users,application programmers, and database administrators. In order to limitthe universe of users with access to data in the database, the systemsecurity administrator should be the only individual with unbridledaccess to the data.

FIG. 1 shows a system level diagram of a conventional databaseapplication, involving a web server 10 hosting a plurality of web sites,namely web site 12 a, web site 12 b and web site 12 c. The web server isconnected to a data communications network 14, such as the Internet,that provides connectivity with a plurality of clients, such as clients16 a and 16 b. The web server includes a single DBMS 18 that serviceseach of the web sites. The DBMS manages data used by the plurality ofweb sites. Since many web sites are hosted by the web server, yet areserved by a single DBMS, security must be provided to preventunauthorized access of data from one web site by a person using anotherweb site hosted by web server 10. In conventional web servers, the DBMSincludes a query processor 20 and a data manager 22. The DBMS 18 isconnected to a data repository 24 that holds data managed by the DBMS.

The query processor 20 processes requests containing queries received ata web site from a client. For example, a typical query might be aStructured Query Language (SQL) query that is received at a web site.The SQL query is passed to the query processor 20 for parsing andexecution by the DBMS. Based on the query, the query processor 20controls the data manager 22 to interact with the data repository 24 tohandle the appropriate data satisfying the query.

FIG. 2A shows an example of a conventional user table (USER.TABLE) 26held within the DBMS shown in FIG. 1. The table contains various columnsof data, labeled Col1, Col2, and Col3 shown in FIG. 2A. The user tablealso includes a security label (SECLABEL) column. Each row is associatedwith a specific security label. Here, the security labels are the namesof various colors such as red, blue, yellow, green, for example. Eachcolor name represents a particular set of security privileges associatedwith the user table row. For example, a security label of “red” may haveone set of access privileges associated with that label, whereas anothersecurity label, such as security label blue, is associated with anotherset of privileges.

Access to USER.TABLE, in a conventional DBMS, is controlled by adatabase view. A system administrator creates a view of the relatedtables within the database in order to restrict access based on a user'ssecurity label.

The system administrator creates a table by using, for example, SQLstatements as shown in FIG. 2B. Here a system administrator creates aview called USER.VIEW 28 a in which the view is selected from threecolumns, namely, U.COL1, U.COL2, U.COL3, as shown in line 28 b of FIG.2. Those columns are selected from the USER.TABLE shown in FIG. 2A. Asecurity table (SECURITY.TABLE) 30 relates a user ID (USERID) with asecurity label (SECLABEL) such as security labels “red”, “blue”, or“green.” This is shown in line 28 c of FIG. 2B. Line 28 d of FIG. 2Brequires that the user security label equals the security label definedin the security table, and that the user ID in the security table equalsthe current user. This limits access to only those rows in USER.TABLE ofFIG. 2A that have a security label equal to the current user's securitylabel. Although this conventional access control scheme provides adegree of access control, it does not support a hierarchical securityscheme.

FIG. 2C shows a relationship between a security table 30 and theresulting view when the SQL statements of FIG. 2B are applied toUSER.VIEW 32. If the view of FIG. 2B is applied for user “SALLY” toaccess the USER.TABLE 26, the result is shown in FIG. 2C. Here, in FIG.2C, when the user SALLY requests access to the USER.TABLE, the view ofFIG. 2B limits SALLY's view of the table 26 to the USER.VIEW 32 shown inFIG. 2C. When the view is applied to table 26, the USER.TABLE 26 isjoined with SECURITY.TABLE 30 to produce USER.VIEW 32.

FIG. 2D shows an example query 34 requested by the user SALLY. SALLY'squery includes a select SQL clause selecting all rows from USER.VIEW.The conventional DBMS system operates by applying the view shown in FIG.2B to the USER.TABLE 26 shown in FIG. 2A. As shown in the SECURITY.TABLE30 of FIG. 2C, SALLY's security label is “blue”, and accordingly, theresulting user view 32 includes only those rows of USER.TABLE 26 havinga security label equal to the security label “blue”. In this manner, aconventional DBMS limits the user's access to only certain rows.However, this conventional access control technique does not supporthierarchical security schemes, and it requires the use of views to limitaccess.

These problems with conventional database management systems can beovercome using the following concepts to provide row-level security.

1. Each end user of the database management system is assigned aSECURITY_LABEL. That label identifies a security level for the userwithin a multilevel security scheme and defines certain privileges foraccessing data in the database. The security label also identifiessecurity categories within that security level that the user is allowedto access. An example of a security category is a software developmentproject on which the user is authorized to work. For example, a givenuser might be allowed to view data designated by certain securitylevels, such as the security levels: TOP SECRET, SECRET, andUNCLASSIFIED. That user also can be permitted to access data thatpertains to certain categories, such as, for example, projects ABC, DEF,and XYZ. The value stored in the security label is encoded in a mannerthat expresses the security level and category information to thesecurity system. An example of such an encoding is the label SECRETABC,where “SECRET” specifies the security level and “ABC” specify securitycategories A, B and C, which could be identifiers of projects on whichthe user is assigned to work.

The user's security label can be determined using different techniques.For example, the user's security label can be determined with a lookupusing the relational DBMS catalog; by making a security call to anexternal security manager; or by a call to a trusted installation exitroutine, for example. It will be understood that other techniques todetermine the user's security label can be employed.

2. Each row within a secure table is associated with a security label,which can be a column within that security table. For example, thatcolumn can have a predetermined name (e.g. SECURITY_LABEL) or it can beidentified through an SQL clause when the table is defined (e.g. ASSECURITY LABEL clause on the CREATE TABLE column definition). It will beunderstood that other techniques can be used to associate a securitylabel with a row.

The SECURITY_LABEL column in the row identifies the security level ofthe data contained in the row, as well as security categories to whichthe row applies. For example, the row might contain data having asecurity level of “SECRET”, that pertains to projects ABC and XYZ(security categories). The value stored in the SECURITY_LABEL is encodedin a manner that expresses the security level and category informationto the security system.

3. A mandatory security enforcement mechanism controls read access tothe secure data rows. That mechanism is activated automatically when arelational database table is known to include a SECURITY_LABEL column.This read security enforcement mechanism compares the user's securitylabel to the row's security label to determine whether access should beallowed. Read access is allowed only if the user's security dominatesthe row's security, in which both of the following conditions are true:

a. The security level indicated by the user's security label is greaterthan or equal to the security level indicated by the row's securitylabel.

b. The security categories associated with the row's security label area proper subset of the security categories associated with the user'ssecurity label.

Write access is controlled separately, so that users can forcecompliance with the general rule of not reading from rows having highersecurity levels than the user or writing to rows having lower securitylevels than the user.

The read and write access security mechanisms can use several varioustechniques to enforce the access scheme, such as by using a lookup withthe relational DBMS catalog; using a security call to an externalsecurity manager; or using a call to a trusted installation exitroutine, for example.

4. A mandatory security enforcement mechanism controls write access tothe secure data rows. This mechanism is activated automatically when arelational database table is known to include a specific column name.The mechanism determines which security label is recorded in the updateddata rows to be written in the database. This write access securitymechanism forces each of those updated rows to contain one of thefollowing possible values.

a. A security label that is the same as the user's security label isused as the security label for the updated row.

b. If a user is specially authorized, that user is allowed to updaterows using a row security label that has a lower level than the user'scurrent security label indicates. The write access security mechanismverifies that the user's security dominates the row's security, suchthat all of the following conditions are true, before allowing the rowto be updated.

-   -   i) The user is specially authorized to write data in a row        having a security label designated for a security level lower        than a security level associated with the user's security label.    -   ii) The security label specified for the row has a security        level that is less than or equal to the security level        associated with the user's security label.    -   iii) The security categories for the security label specified        for the row are a proper subset of the security categories        associated with the user's security label. That is, all the        security categories associated with the row's label are also        associated with the user's security label.

The write access security mechanism uses several different techniques toenforce the access scheme. For example, it can perform a lookup with therelational DBMS catalog; make a security call to an external securitymanager; or make a call to a trusted installation exit routine.

A DBMS that supports mandatory access control at the row level isillustrated in FIG. 3. Here, the DBMS 18, in addition to a query manager20 and a data manager 22, also includes a read mandatory security unit36 and a write mandatory security unit 38. An exemplary embodiment ofDBMS 18 is IBM's DB2® for the z/OS® operating system. Each mandatorysecurity unit is coupled to the data manager 22 and to the data storageunit 24. Both of the mandatory security units operate to control accessby a user, or application program 40 such as a web site, to the dataaccording to a hierarchical security scheme.

By placing the mandatory security units between the data manager 22 andthe data repository 24, mandatory access control is achieved. If thedata manager 22 attempts to read a row of data from the data storageunit 24, the request is directed through the read mandatory securityunit 36. That security unit compares a user's security label passed bythe data manager with a security label associated with the requested rowof data in the data storage unit 24. If the conditions discussed aboveare met, access to the row is granted. That is, the read mandatorysecurity unit 36 determines, from the user's security label, the user'ssecurity level and security categories. It also determines, from therow's security label, the row security level and row securitycategories. If the user's security level is greater than or equal to thesecurity level for the row, and if the security categories associatedwith the row are a proper subset of the security categories associatedwith the user's security level, then read access is allowed. Since everyattempted read access to the data passes through the read mandatorysecurity unit, mandatory access control is achieved.

Similarly, when writing an updated row to the database, the writemandatory security unit 38 receives from the data manager 22 the requestto store the row in the data storage unit 24. The write mandatorysecurity unit 38 ensures that the conditions discussed above are metbefore allowing the row to be updated in the data storage unit 24. Thatis, the write mandatory security unit ensures that the user's securitylabel indicates both that the user's security level and securitycategories correspond with the security level and categories indicatedby the security label of the row to be updated.

A hierarchical security scheme is illustrated, conceptually, in FIG. 4.Here, the security scheme shows security levels labeled using names ofcolors. For example, security level 42 bears the label “red,” securitylevel 44 bears the label “orange,” and the security level 46 bears thelabel “yellow.” Similarly, security level 48 bears the label “green,”level 50 bears the label “blue,” level 52 bears the label “indigo,” andlevel 54 bears the label “violet.” These security levels, namely thecolor names, are similar to the security label shown in FIG. 2A used ina conventional database. However, the scheme shown in FIG. 4 is ahierarchical security scheme in which security levels are groupedtogether to create different levels of security in a multilevel securitysystem. For example, the security level 56 bearing the label “sunset”includes all the access privileges for the lower level security labelswithin its branch, namely, red, orange and yellow. Accordingly, thesecurity label sunset is located at a higher level in the securityscheme than the security labels red, orange and yellow. Similarly, thesecurity level 58, labeled “pastel,” includes all the privileges of thelower level security labels in its branch, namely, security labels blue,indigo, and violet. In this manner the pastel security label is locatedat a higher level in the hierarchical security scheme than the labelsblue, indigo and violet.

Security level 60, labeled “rainbow” is located at the highest level ofthe security hierarchy. As shown in FIG. 4, the rainbow label includesall the privileges of every security label in the tree structure shownin FIG. 4. This hierarchical security scheme supports multilevel accesscontrol.

In a DBMS employing the mandatory security access controls describedhere, a user may query the DBMS tables directly and mandatory accesscontrol is automatically performed. This allows a query, such as query62 shown in FIG. 5A, to be applied to the DBMS without having to use aview to control access as in a conventional DBMS. Here, a query from“BOSS 2,” shown in FIG. 5A, includes a SELECT clause 62. The SELECTclause is intended to select all data from the user table “USER.TABLE.”If the DBMS does not include any access control, the contents of theentire table would be returned regardless of the user's security level.However, when this query is applied to the DBMS having the mandatoryaccess controls, shown in FIG. 3, the only rows of data that arereturned are the rows that the user is authorized to access.

This control aspect is illustrated in FIG. 5B. Here, the user table 26includes rows that each bear a security label, namely a security label“red,” “blue,” “yellow,” etc. When the query shown in FIG. 5A,originating from a user or an application 40, is received by the DBMSthe query processor 20 processes the query and sends requests to thedata manager 22 to select all rows of the USER.TABLE 26. However, theread security unit 36 operates to limit the rows of the user table thatare returned based on a security mechanism 64. A variety of securitymechanisms can be used, such as a table as shown in FIG. 5B, thatrelates a user ID to a security label for the user. Although, it will beunderstood that other security mechanisms can be used to determine asecurity label associated with a user.

The security label might be a security level at a leaf node in thehierarchy shown in FIG. 4, such as security label “red” shown in row 64a. However, the security label might be a higher level label such as thesecurity level “rainbow” shown in row 64 b of the security mechanism 64.For example the user “BOSS 1” has access privileges defined in table 64by the label “rainbow” in row 64 b, thereby giving that user a higherdegree of access. Similarly, another user, e.g., “BIG BOSS,” also canuse the same high level label, such as the rainbow security level, asillustrated in row 64 c.

Another example of a hierarchical security level is shown in row 64 dfor the user ID “BOSS 2.” BOSS 2 has a security label “sunset.” As shownin FIG. 4, BOSS 2, having a security label of “sunset,” has accessprivileges that include all the privileges of security labels red,orange, and yellow. Accordingly, when BOSS 2 submits the query shown inFIG. 5A, the read mandatory security unit compares the security labelfor BOSS 2 with the security labels for each of the rows in USER.TABLE26. Since the “sunset” label includes all the privileges of the red,yellow, and orange security labels, the read mandatory security unit 36returns the rows 26 a, having a security label “red,” row 26 c having asecurity label “yellow,” and row 26 g having a security label “red.”Since those security labels are subordinate in the hierarchy to the“sunset” label, as shown in FIG. 4, the other rows, namely, rows 26 b,26 d, 26 e, 26 f, and 26 h, are not returned because the security labelsfor those rows are not within the “sunset” branch of the hierarchy shownin FIG. 4. In this manner, the user BOSS 2 can submit query 62 shown inFIG. 5A without using a view to limit access to only those rows having asecurity level the same as or at a lower level than the security labelassociated with BOSS 2.

FIG. 6 illustrates an alternative embodiment of the DBMS system shown inFIG. 3. Here a cache is employed to improve performance. The cacheoperates to store the security label information in readily availablememory so that every time a row is accessed the security label need notbe interpreted, whether by calling an external routine or performing alook-up to determine the security level and associated privileges, andcategories associated with the particular security label. Here, the DBMSincludes a cache 66 for holding the security label information that isdetermined for each query that is processed for a specific user.

In the embodiment shown in FIG. 6, a user submits an SQL query 68 to theDBMS. The query processor 20 processes the received query in aconventional manner. As shown in FIG. 6, the query begins by opening acursor and executing a loop. The loop includes getting the next rowwhich causes interaction with the data manager/mandatory security unit70 shown in FIG. 6. The data manager/mandatory security unit 70 caninclude the functions of both the data manager and the read mandatorysecurity units 36 and write mandatory security units 38 shown in FIG. 3,either individually or in combination. Here, in FIG. 6, they are shownin the same unit. For ease of description, the data manager/mandatorysecurity unit 70 will be referred to simply as “data manager” 70.

The data manager 70 retrieves the next row from the data storage unit24. Upon retrieving a row from the data storage unit 24 the data manager70 performs the mandatory security function of checking whether thereturned row includes a security label. If so, the cache 66 is searchedto determine if information associated with that security label isalready present in the cache. If so, the security information within thecache is used to compare the user security level with the security levelassociated with the retrieved row. If the security label is not found inthe cache then the data manager 70 determines the information associatedwith the security label. This can be performed in various ways, such asby calling a security layer, as illustrated in FIG. 6. The result of thesecurity label information determination is then placed in the cache 66to thereby cache the result of the security label call.

Once the security information is available, the security level andcategory of the label associated with the retrieved row are comparedwith the security level and category associated with the user's securitylabel. A determination then is made whether to allow the user to accessthat row.

If the result of the comparison is that the user is to be given access,then the row is returned to the query processor 20 for return to theuser. The loop shown in the query processor 20 then continues until thequery is complete.

When the query is complete, the query processor notifies the datamanager which then purges the cache. In this manner, the cacheinformation is used only for a single query by a single user. In otherwords, for each query made by a user, the security label informationheld in the cache is refreshed so that the information in the cache ispresent only during the time when a user's query is processed. A user'ssecurity level and a row's security level are assumed to stay unchangedduring the period when a query is performed. However, by purging thecache after each query, changes to both the user's security level and tothe security levels of rows in the data can occur without having toinvalidate information held in the cache.

The following are examples of processes that can be used to providerow-level security with mandatory access control.

When a database administrator creates a table in the DBMS shown in FIG.3, the administrator includes a SECURITY_LABEL column in the table. Theadministrator also can add a SECURITY_LABEL column to a table to beprotected. The DBMS uses the presence of the SECURITY_LABEL column toautomatically activate row-level security. Thus, the row-level securitymechanism is driven by the presence of the SECURITY_LABEL column and thecontent of the data row. The SECURITY_LABEL column enables the use ofsecurity controls for rows in a database that do not depend upondatabase administrators creating special views that identify the rowsthat each user is allowed to access. Such security controls makerow-level security mandatory for the table whenever the security labelis present, and those controls cannot be bypassed by directly accessingthe table (i.e. using or avoiding special views that control rowaccess). The security label stored in each row has an encoded value thatencapsulates the following two specific pieces of information.

-   -   a. The security level of the data contained in the row. This        allows implementation of multilevel, hierarchical security        schemes (e.g., TOP SECRET, SECRET, UNCLASSIFIED).    -   b. The security categories to which this row of data applies.        For example, a row of data might be associated with six security        categories (e.g., projects A, B, C, D, E, F on which the row is        used). The security label can be encoded in a manner that allows        the security mechanism to determine the subset of the possible        security categories to which this row of data pertains.

When the end user logs on to the DBMS, the user will provideauthentication tokens (e.g., userid/password, KERBEROS ticket, etc.)that identify the user to the DBMS. Once the user's identity has beenascertained, the DBMS determines the security label associated with theend user. This can be done using many different techniques, such as viaa table lookup in the DBMS's authorization tables; via a security checkto an external security product; or via a trusted user exit routine, forexample. As with the security label for the row, the user's securitylabel is encoded to encapsulate the following information.

-   -   a. The security level of the data the user is authorized to        access. This allows implementation of multilevel, hierarchical        security schemes (e.g., TOP SECRET, SECRET, UNCLASSIFIED        levels).    -   b. The security categories the user is associated with and        authorized to access. For example, a user might be associated        with three different projects (e.g., projects A, B and C, each        of which can be designated as a security category).

FIG. 7A illustrates a process for a user to query a database in whichmandatory access controls are present. A user, in operation 72, preparesa query for submission to a DBMS that has a table that includes aSECURITY_LABEL column. The user, by logging on to the DBMS or by anothermethod, is identified to the DBMS. The user's security level andsecurity categories are determined in operation 74 using the techniquesdescribed earlier. A request with the user's query is prepared inoperation 76 by a client, for example, in a client/server system. Therequest includes, in addition to the query, a user security labelencoded with the user's security level and security categories. Therequest is sent in operation 78 to the DBMS.

Referring to FIG. 7B, the DBMS receives the user's request in operation80. In operation 82 the DBMS, through the query processor and datamanager, processes the query and scans the requested tables to find rowsthat satisfy the user's query predicates. Before returning any data tothe user application, the DBMS invokes the security mechanism todetermine whether the user is authorized to view the data. The firstdecision, in operation 84, is to determine if the database table has aSECURITY_LABEL column. If the table does not have a SECURITY_LABELcolumn, then the query is processed in a conventional manner inoperation 86 and the results of the query are returned to the user inoperation 88.

If the table has a SECURITY_LABEL column, then the security mechanism isinvoked in operation 90 where the user's security level and securitycategories are determined by decoding the user's security label. Therow's security label is retrieved from the SECURITY_LABEL column anddecoded. The security mechanism can be implemented in many ways, such asvia a lookup within the DBMS's authorization tables, via a call to anexternal security product, or via an installation exit routine, forexample. The security mechanism is responsible for examining the row'ssecurity label to determine whether the user is authorized to retrievethat particular row. This is accomplished in operation 92 by comparingthe user's security level with the row's security level. There are twopossible cases for each row.

a. The security label of the row has a value that is within a range ofvalues that are accessible to the user. This is the case when the user'ssecurity dominates the row's security, both of the following conditionsare true.

-   -   i) The security level indicated by the user's security label is        greater than or equal to the security level indicated by the        row's security label, as determined in operation 94. If not, the        user is denied access to the row in operation 96. If so, then        the next condition is tested in operation 98.    -   ii) The security categories associated with the row's security        label are a proper subset of the security categories associated        with the user's security label, as determined in operation 98.        If that is the case, the DBMS processes the row and retrieves        the requested data values and returns the result to the user in        operation 102. If not, the user is denied access to the row in        operation 100.

b. The security label associated with the row is outside the range ofvalues corresponding to the user's security label. In this case, theDBMS either ignores the row, or declares an attempted security violationdepending upon the security policy employed for the database managementsystem. The user is thus denied access to the protected row, as shown inoperations 96 and 100.

To minimize the computer processor usage and elapsed time associatedwith the row-level security checks, the DBMS can cache the row securitylabel values that were authenticated successfully during the course ofrunning the transaction, in cache 66 shown in FIG. 6, during the courseof processing a user's transaction. If subsequent rows are encounteredwith security label values that are already present in the user's cache,the security check can be bypassed, since that particular security labelvalue already passed the security check. The cache of validated securitylabel values is destroyed at database commit and rollback boundaries, sothat subsequent changes in the security policy are reflected in the nextunit of work.

Having the security mechanism check both security level and securitycategory gives the security mechanism a great deal of flexibility insupporting various security policies. Some examples of this include thefollowing.

a. An installation might choose to allow access only on an exact match(user security label=“RED” and row security label=“RED”).

b. An installation might choose to allow access only when the row'ssecurity label is a proper subset of the user's security label (usersecurity label=“RAINBOW” which means “RED,” “ORANGE,” “YELLOW,” “GREEN,”“BLUE,” “INDIGO,” and “VIOLET” are allowable values for the row securitylabel for this user).

c. An installation might choose to allow access based on a hierarchy.For example, a “TOP SECRET” security label for the user would allowaccess to all security levels at that same level and below, namely for“TOP SECRET”, “SECRET”, and “UNCLASSIFIED” row security label values.

d. Combinations of the above schemes also can be used, depending on theapplication.

Referring to FIG. 8A, when the user, in operation 104, requests anupdate to data in a row of a database table, either a change to the datain the row or inserting a row, the user is identified and the user'ssecurity level and security categories are determined in operation 106.A request is prepared in operation 108 that includes the row update aswell as the user's security level and categories. That request is thensent to the DBMS in operation 110.

Referring to FIG. 8B, once the user issues an update request, such as anSQL request that updates data (INSERT, UPDATE, etc.), the DBMS receivesthat request in operation 112. The request includes the update to thedata in the row and the user's security label which indicates the user'ssecurity level and security categories. The security mechanismdetermines a security label to associate with the updated row, inoperation 114. In this embodiment, the user's security label is used asthe security label for the updated row. Alternatively, a differentsecurity label can be selected, based on criteria appropriate for theapplication and operating environment. In operation 116 the securitymechanism determines if the row to be updated contains a SECURITY_LABELcolumn. If not, the update is processed in a conventional manner inoperation 118.

If the row includes a SECURITY_LABEL column, then operation 120 isperformed which determines if the user's security label is equal to thesecurity label for the row. If it is, the update is performed inoperation 122, and the row's security label is set equal to the user'ssecurity label.

If the user's security label is not equal to the row's security label,then it is determined in operation 124 if the user is speciallyauthorized to record updates with a security level that is differentfrom the user's security level. If the user is not specially authorized,then access for making the update to the table is denied in operation126. However, if the user is specially authorized, then the user'ssecurity level, determined from the user's security label, is comparedwith the security level for the row to be updated, in operation 128 todetermine if the user's security dominates the row's security. In thisoperation the user's security label and the row's security label aredecoded to determine the security information encoded therein. Thisdecoding operation can be implemented using many different techniques,such as via a lookup within the DBMS's authorization tables; via a callto an external security product; or via an installation exit routine,for example. The information from the decoded security labels, such asthe security level information, is compared in operation 128.

Following connector “A” to FIG. 8C, in operation 130 it is determined,based on the comparison, if the user's security level is greater than orequal to the security level for the row. If not, the user is deniedaccess to the row to make the update, in operation 132. However, if theuser's security level is greater than or equal to the row's securitylevel, then operation 134 is performed to compare security categories.

In operation 134, if the security categories of the row to be updatedform a proper subset of the user's security categories, then the updatedrow is recorded in the database, in operation 136. The securitycategories for the row form a proper subset of the security categoriesfor the user if all of the row's security categories are included in theset of security categories for the user. However, if the securitycategories for a row do not form a proper subset of the securitycategories of the user, then in operation 138 the user is denied accessto update the row.

In updating a row, the security mechanism, such as the write mandatorysecurity unit 38, shown in FIG. 3, can be provided not only with theuser's security label value but also with a proposed value of the row'ssecurity label. That proposed value can be provided, for example, by theuser's SQL update operation. The security mechanism can choose to allowthe row's security label to be recorded without change, or it can chooseto force a different value into the row's security label based on theinstallation's security policy. This allows installations to employ anydesired security policy. For example, a security policy can be chosen toforce all updates to record in the modified row's security label thesecurity label of the user who made the update. An alternative securitypolicy can be chosen to allow selected users to make updates with rowsecurity label values that are different than the user's security label.Examples of such a security label value are a value that is a propersubset of the user's security label values, and a value that is lessthan or equal to the user's security level.

IBM Corporation's Resource Access Control Facility (RACF®) is an exampleof a product that can be used to perform the functions of the mandatorysecurity units. According to one embodiment, a database table canactivate row level security support by adding a specially named columnthat acts as the security label. A RACF® exit is used to check for eachsecurity label value that is accessed within a cursor, and determinewhether a SQL query requester submitting an SQL query is allowed toaccess the data row. The security layer in RACF® will understandhierarchical relationships such as the hierarchy representing the colorsof the rainbow illustrated in FIG. 4.

With that hierarchy established in RACF®, the DBMS understands thatusers with authority to access pastel information can access any rowassociated with blue, indigo, violet, or pastel. With these capabilitiesthat type of security scheme can be implemented without requiringapplication programs to access the data using special views orpredicates.

Having described apparatuses, articles of manufacture and methods ofproviding row-level security in a relational database management system,it is believed that other modifications, variations and changes will besuggested to those skilled in the art in view of the teachings set forthherein. It is therefore to be understood that all such variations,modifications and changes are believed to fall within the scope of thepresent invention as defined by the appended claims. Although specificterms are employed herein, they are used in their ordinary andaccustomed manner only, unless expressly defined differently herein, andnot for purposes of limitation.

Trademarks

IBM, DB2, z/OS and RACF are trademarks or registered trademarks ofInternational Business Machines, Corporation in the United States andother countries.

What is claimed is:
 1. A computer-implemented method of controlling access to a relational database, comprising: receiving, by using a computer system, a user request for data from the database, the request including a request to perform a database operation and a user security label; determining whether a security label column is included in a table of the database, the security label column storing, in each row of the table, a security label, which indicates a security level required by a user of the user request to access the data contained in the respective row in the table; and automatically activating a mandatory security enforcement mechanism, independent of the database operation to access the database, as a result of determination that the security label column is included in the table of the database; wherein the mandatory security enforcement mechanism is automatically activated independent of creating a view based on the database operation to access the database; the mandatory security enforcement mechanism including: determining user security information from the user security label; determining row security information for each row from the security label column in each row; comparing the user security information and the row security information; retrieving rows of data from the table in the database based on the result of the comparison; and returning only the rows for which the user is determined to have authorization to access for performing the database operation on the rows.
 2. The method of claim 1, wherein the request contains one or more queries of one or more tables.
 3. The method of claim 1, wherein the table containing the rows of data contains access control information for limiting user access to the database.
 4. The method of claim 1, wherein the database operation is a query.
 5. The method of claim 1, wherein the database operation involves a row update.
 6. The method of claim 1, wherein said determining row security information includes checking a cache for row security information corresponding to the row's security label.
 7. The method of claim 1, wherein the user security label is one of plurality of security labels arranged in a hierarchy of security levels.
 8. The method of claim 7, wherein the user is determined to be authorized to access the retrieved row only if the user security label corresponds to a security level having a greater than or equal degree of access than a security level indicated by the retrieved row's security label.
 9. The method of claim 1, wherein the user is authorized to modify the row only when the user security information is equal to the row security information.
 10. A computer-implemented method of controlling access to data in at least one row of a database, wherein said at least one row is associated with row-level access control information, the method comprising: receiving, by using a computer system, a request from a user to operate on the database, the request including the request to perform a database operation and a user security label; determining whether a security label column is included in a table of the database, the security label column storing, in each row of the table, a security label, which indicates a security level required by a user of the request to access the data contained in the respective row in the table; and automatically applying mandatory access control rules independent of a database operation in the request from the user, as a result of determination that the security label column is included in the table of the database, to rows of the database satisfying the request by determining whether privileges associated with the a first security level are included in the privileges associated with a second security level, determining row security information for each row from the security label column in each row, and comparing a user security information and a row security information, wherein mandatory access control rule of the rules in automatically activated independent of creating a view based on the database operation to access the database; and returning data from the row if the security level associated with the row is at least a subset of the security level of the user, to perform the database operation on the row.
 11. The method of claim 10, wherein the request is a Structured Query Language (SQL) query.
 12. The method of claim 10, wherein the database is comprised of a plurality of tables and the received request includes a request for access to at least one of the plurality of tables.
 13. A computer-implemented method of controlling a user's access to data in rows of a database, the method comprising: receiving, by using a computer system, a request from the user to operate on the database, the request including the request to perform a database operation and a user security label; determining whether a security label column is included in a table of the database, the security label column storing, in each row of the table, the first access level, which indicates a security level required by a user of the request to access the data contained in the respective row in the table; and automatically activating a mandatory security enforcement mechanism, independent of the database operation to access the database, as a result of determination that the security label column is included in the table of the database, wherein the mandatory security enforcement mechanism is automatically activated independent of creating a view based on the database operation to access the database; the mandatory security enforcement mechanism including: determining whether the user is authorized to operate on a row of the database that satisfies the request by comparing the first access level stored in the column of the table and the second access level and determining whether privileges associated with the first access level are included in the privileges associated with the second access level; and returning data from the row only if the user is determined to be authorized to perform the database operation on the row.
 14. The method of claim 10, wherein the subset of the security level of the user corresponds to all security levels equal to or lower than the security level of the user.
 15. The method of claim 10, wherein the subset of the security level of the user corresponds to all security levels equal to or lower than the security level of the user.
 16. The method of claim 13, wherein the determining whether the privileges associated with the first access level are included in the privileges associated with the second access level comprising: determining whether the first access level is equal to or lower than the second access level.
 17. The method of claim 1, wherein the table in the database has a column in which the security label corresponding to each of the rows are stored respectively.
 18. The method of claim 10, wherein the applying mandatory access control rules is activated automatically when a relational table in the database includes a security label column in which the security label corresponding to each of the rows in the relational table are stored respectively. 